import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[] tem = new int[t];
        for (int i = 1; i < t+1; i++) {
            tem[i-1] = i;
        }
        dfs(tem,new ArrayList<>(),new int[t]);
    }
    static void dfs(int[] tem, List<Integer> now,int[] vis){
        if (now.size()==tem.length)
            System.out.println(now);
        for (int i = 0; i < tem.length; i++) {
            if (vis[i]==0){
                now.add(tem[i]);
                vis[i] = 1;
                dfs(tem,now,vis);
                vis[i] = 0;
                now.remove(now.size()-1);
            }
        }
    }
}